package org.sdp.pearproject.controller;


import org.sdp.pearproject.controller.custom.*;
import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;

import java.util.List;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName: TaskTagController
 * @Description:
 * @Author: SDP
 * @Date: 2022-07-18
 * @Version: 1.0
 * Table: pear_task_tag
 * Comment:
 * 任务标签表
 */
@RestController
@RequestMapping(value = "/task_tag")
public class TaskTagController extends TaskTagCustomController {
    static {
        addRequestClass("task_tag", "add", "taskTagController", TaskTagController.class, TaskTagAddRequest.class);
        addRequestClass("task_tag", "add_encrypt", "taskTagController", TaskTagController.class, TaskTagAddRequest.class);

        addRequestClass("task_tag", "update", "taskTagController", TaskTagController.class, TaskTagUpdateRequest.class);
        addRequestClass("task_tag", "update_encrypt", "taskTagController", TaskTagController.class, TaskTagUpdateRequest.class);

        addRequestClass("task_tag", "delete", "taskTagController", TaskTagController.class, TaskTagDeleteRequest.class);
        addRequestClass("task_tag", "delete_encrypt", "taskTagController", TaskTagController.class, TaskTagDeleteRequest.class);

        addRequestClass("task_tag", "query", "taskTagController", TaskTagController.class, TaskTagQueryRequest.class);
        addRequestClass("task_tag", "query_encrypt", "taskTagController", TaskTagController.class, TaskTagQueryRequest.class);

        addRequestClass("task_tag", "list", "taskTagController", TaskTagController.class, TaskTagQueryRequest.class);
        addRequestClass("task_tag", "list_encrypt", "taskTagController", TaskTagController.class, TaskTagQueryRequest.class);

        addRequestClass("task_tag", "count", "taskTagController", TaskTagController.class, TaskTagQueryRequest.class);
        addRequestClass("task_tag", "count_encrypt", "taskTagController", TaskTagController.class, TaskTagQueryRequest.class);

        addRequestClass("task_tag", "stat", "taskTagController", TaskTagController.class, TaskTagQueryRequest.class);
        addRequestClass("task_tag", "stat_encrypt", "taskTagController", TaskTagController.class, TaskTagQueryRequest.class);

    }

    @PostMapping("/add")
    public Integer addTaskTag(@MixRequestBody TaskTagAddRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("task_tag", "add", request, callFromEncrypt);
        return super.addTaskTag(request);
    }

    @PostMapping("/add_encrypt")
    public String addTaskTagEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskTagAddRequest request = (TaskTagAddRequest) super.decrypt("task_tag", "add_encrypt", strRequest, TaskTagAddRequest.class);
        Integer result = addTaskTag(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/update")
    public Integer updateTaskTag(@MixRequestBody TaskTagUpdateRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("task_tag", "update", request, callFromEncrypt);
        return super.updateTaskTag(request);
    }

    @PostMapping("/update_encrypt")
    public String updateTaskTagEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskTagUpdateRequest request = (TaskTagUpdateRequest) super.decrypt("task_tag", "update_encrypt", strRequest, TaskTagUpdateRequest.class);
        Integer result = updateTaskTag(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/delete")
    public Integer deleteTaskTag(@MixRequestBody TaskTagDeleteRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("task_tag", "delete", request, callFromEncrypt);
        return super.deleteTaskTag(request);
    }

    @PostMapping("/delete_encrypt")
    public String deleteTaskTagEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskTagDeleteRequest request = (TaskTagDeleteRequest) super.decrypt("task_tag", "delete_encrypt", strRequest, TaskTagDeleteRequest.class);
        Integer result = deleteTaskTag(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/query")
    public TaskTagQueryResponse queryTaskTag(@MixRequestBody TaskTagQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("task_tag", "query", request, callFromEncrypt);
      return super.queryTaskTag(request);
    }

    @PostMapping("/query_encrypt")
    public String queryTaskTagEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskTagQueryRequest request = (TaskTagQueryRequest) super.decrypt("task_tag", "query_encrypt", strRequest, TaskTagQueryRequest.class);
        TaskTagQueryResponse result = queryTaskTag(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/list")
    public List<TaskTagQueryResponse> listTaskTag(@MixRequestBody TaskTagQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("task_tag", "list", request, callFromEncrypt);
        if (super.needTotal("task_tag", "list", request)) {
            super.setTotal("task_tag", "list", request, super.countTaskTag(request));
        }
        return super.listTaskTag(request);
    }

    @PostMapping("/list_encrypt")
    public String listTaskTagEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskTagQueryRequest request = (TaskTagQueryRequest) super.decrypt("task_tag", "list_encrypt", strRequest, TaskTagQueryRequest.class);
        List<TaskTagQueryResponse> result = listTaskTag(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/count")
    public Integer countTaskTag(@MixRequestBody TaskTagQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("task_tag", "count", request, callFromEncrypt);
      return super.countTaskTag(request);
    }


    @PostMapping("/count_encrypt")
    public String countTaskTagEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskTagQueryRequest request = (TaskTagQueryRequest) super.decrypt("task_tag", "count_encrypt", strRequest, TaskTagQueryRequest.class);
        Integer result = countTaskTag(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/stat")
    public BaseStatResponse statTaskTag(@MixRequestBody TaskTagQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("task_tag", "stat", request, callFromEncrypt);
        return super.statTaskTag(request);
    }

    @PostMapping("/stat_encrypt")
    public String statTaskTagEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskTagQueryRequest request = (TaskTagQueryRequest) super.decrypt("task_tag", "stat_encrypt", strRequest, TaskTagQueryRequest.class);
        BaseStatResponse result = statTaskTag(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    static {
        addRequestClass("task_tag", "tags", "taskTagController", TaskTagController.class, TaskTagForTagsRequest.class);
        addRequestClass("task_tag", "tags_encrypt", "taskTagController", TaskTagController.class, TaskTagForTagsRequest.class);
    
        addRequestClass("task_tag", "count_tags", "taskTagController", TaskTagController.class, TaskTagForTagsRequest.class);
        addRequestClass("task_tag", "count_tags_encrypt", "taskTagController", TaskTagController.class, TaskTagForTagsRequest.class);
    
        addRequestClass("task_tag", "stat_tags", "taskTagController", TaskTagController.class, TaskTagForTagsRequest.class);
        addRequestClass("task_tag", "stat_tags_encrypt", "taskTagController", TaskTagController.class, TaskTagForTagsRequest.class);
    
        addRequestClass("task_tag", "export_excel_tags", "taskTagController", TaskTagController.class, TaskTagForTagsRequest.class);
        addRequestClass("task_tag", "export_excel_tags_encrypt", "taskTagController", TaskTagController.class, TaskTagForTagsRequest.class);
    }

    @PostMapping("/tags")
    public List<TaskTagForTagsResponse> tags(@MixRequestBody TaskTagForTagsRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("task_tag", "tags", request, callFromEncrypt);
        if (super.needTotal("task_tag", "tags", request)) {
            super.setTotal("task_tag", "tags", request, super.countForTags(request));
        }
        return super.tags(request);
    }

    @PostMapping("/tags_encrypt")
    public String tagsEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskTagForTagsRequest request = (TaskTagForTagsRequest)decrypt("task_tag", "tags_encrypt", strRequest, TaskTagForTagsRequest.class);
        List<TaskTagForTagsResponse> result = tags(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);
        
        return super.encrypt(request, response);
    }

    @PostMapping("/count_tags")
    public Integer countForTags(@MixRequestBody TaskTagForTagsRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("task_tag", "count_tags", request, callFromEncrypt);
        return super.countForTags(request);
    }

    @PostMapping("/count_tags_encrypt")
    public String countForTagsEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskTagForTagsRequest request = (TaskTagForTagsRequest)decrypt("task_tag", "count_for_tags_encrypt", strRequest, TaskTagForTagsRequest.class);
        Integer result = countForTags(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);
        
        return super.encrypt(request, response);
    }

    @PostMapping("/stat_tags")
    public BaseStatResponse statForTags(@MixRequestBody TaskTagForTagsRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("task_tag", "stat_tags", request, callFromEncrypt);
        return super.statForTags(request);
    }

    @PostMapping("/stat_tags_encrypt")
    public String statForTagsEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskTagForTagsRequest request = (TaskTagForTagsRequest)decrypt("task_tag", "stat_for_tags_encrypt", strRequest, TaskTagForTagsRequest.class);
        BaseStatResponse result = statForTags(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);
        
        return super.encrypt(request, response);
    }

    @ResponseBody
    @PostMapping("/export_excel_tags")
    public String exportExcelTags(@MixRequestBody TaskTagForTagsRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("task_tag", "export_excel_tags", request, callFromEncrypt);
        return super.exportExcelTags(request);
    }

    @ResponseBody
    @PostMapping("/export_excel_tags_encrypt")
    public String exportExcelTagsEncrypt(@MixRequestBody String strRequest) throws Exception {
        TaskTagForTagsRequest request = (TaskTagForTagsRequest)decrypt("task_tag", "export_excel_tags_encrypt", strRequest, TaskTagForTagsRequest.class);
        String result = exportExcelTags(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);
        
        return super.encrypt(request, response);
    }


}
